//Copyright (c) 2006-2007 Microsoft Corporation.  All rights reserved
using System;

using InvocationFramework.Adapters.Inproc.Transactions;

namespace InvocationFramework.Adapters.Inproc.Attributes
{
    /// <summary>
    /// Atributo utilizado para especificar el nivel de transaccionalidad de un servicio
    /// </summary>
    [AttributeUsage( AttributeTargets.Method, Inherited = true, AllowMultiple = false )]
    public sealed class TransactionAttribute : Attribute
    {
        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="transactionType">Especifica el tipo de transaccion solicitado por un servicio</param>
        public TransactionAttribute( TransactionScope transactionType )
        {
            _transactionType = transactionType;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Variable privada para el manejo de la propiedad
        /// </summary>
        private readonly TransactionScope _transactionType = TransactionScope.Disabled;

        /// <summary>
        /// Especifica el tipo de transaccion solicitado por un servicio
        /// </summary>
        public TransactionScope TransactionType
        {
            get
            {
                return _transactionType;
            }
        }

        /// <summary>
        /// Variable privada para el manejo de la propiedad
        /// </summary>
        private IsolationLevel _transactionIsolation = IsolationLevel.Serializable;

        /// <summary>
        /// Especifica el nivel de lockeo de una transaccion
        /// </summary>
        public IsolationLevel TransactionIsolation
        {
            get
            {
                return _transactionIsolation;
            }
            set
            {
                _transactionIsolation = value;
            }
        }

        /// <summary>
        /// Variable privada para el manejo de la propiedad
        /// </summary>
        private TimeSpan _transactionTimeout = TimeSpan.Zero;

        /// <summary>
        /// Especifica el timeout de la transaccion
        /// </summary>
        public TimeSpan TransactionTimeout
        {
            get
            {
                return _transactionTimeout;
            }
            set
            {
                _transactionTimeout = value;
            }
        }
        
        #endregion    
    }
}